package com.leyou.page.controller;

import com.leyou.page.service.PageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.Map;

@Controller
public class PageController {

    @Autowired
    private PageService pageService;
//门户点击图片产品后会发出此地址
    @GetMapping("item/{id}.html")
    public String genItemHtml(Model model, @PathVariable("id") Long id){
        Map<String,Object> map =  pageService.loadData(id);
        //将数据封装到域中,并返回给模板中(item.html模板)
        model.addAllAttributes(map);

        return "item";
    }

}
